package top.kaoshanji.ch02;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * 代码清单 ch02-02：FileVisitor示例(2.3.2节、遍历目录树)
 * API文档有示例
 * author kaoshanji
 * ^_^
 * create time 2024/12/13 16:05
 */
public class FileVisitorDemo {

    private static final Logger logger = LogManager.getLogger(FileVisitorDemo.class);

    public static void main(String[] args) throws IOException {
        logger.info("...代码清单 ch02-02：FileVisitor示例(2.3.2节、遍历目录树)...");

        // 设定起始目录
        Path startingDir = Paths.get("D:\\works\\workspace\\java7developer");

        // 调用 walkFileTree
        // 具体的逻辑在 FindJavaVisitor 类里面
        Files.walkFileTree(startingDir, new FindJavaVisitor());

    }

}
